home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
PCMAP.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-04-22
|
39KB
|
1,105 lines
page 58,132
;----------------------------------------------------------------
; PCMAP 2.0 - Jeff Hasty (CompuServe 71121,2352) - April, 1989
; Documentation in PCMAP2.DOC
;----------------------------------------------------------------
;----------------------------------------------------------------
; EQUATES
;----------------------------------------------------------------
MAX_BLK EQU 23 ;Number of spaces in table
INT9_BUSY EQU 1 ;Mask for BUSY byte
INT10_BUSY EQU 2 ;Mask for BUSY byte
SHIFT_MASK EQU 8 ;Mask for hot key (8=Alt)
HOTKEY EQU 19H ;Scan code (19h=P)
CR EQU 0DH ; ASCII carriage return
LF EQU 0AH ; ASCII line feed
TAB EQU 09h ; ASCII tab
BLANK EQU 20h ; ASCII space character
;----------------------------------------------------------------
; START - entry point for command-line mode
;----------------------------------------------------------------
_TEXT SEGMENT PARA PUBLIC 'CODE' ;set up for .COM file
ASSUME CS:_TEXT,DS:_TEXT
ORG 100H
START:
JMP RES ;jump to installation routines
;----------------------------------------------------------------
; RESIDENT DATA AREA
;----------------------------------------------------------------
ID DB "PCMAP 2.0 - Jeff Hasty (CompuServe 71121,2352)"
DB " - April, 1989",1Ah
HEADING_MSG DB CR,LF
DB "Segment Size Program"
DB CR,LF
DB "Address Owner (para) Type Name"
DB CR,LF
DB "0000",18 DUP(' '),0
BLOCK1_MSG DB 10 DUP (' '),"DOS + Drivers",CR,LF,0
CR_LF_MSG DB CR,LF,0
COM_MSG DB "COMMAND.COM"
PSP_MSG DB "PSP"
ENV_MSG DB "ENV"
UNK_MSG DB "(Unknown)"
FREE_MSG DB "(Free)"
SPACE3_MSG DB " "
SPACE_MSG DB 7 DUP(' '),0
TABLE_FULL_MSG DB "Out of space ",0
PROGRAM_ID DB "PCMAP 2.0",0
HIT_ANY_KEY DB " - Hit any key to return...",0
DISABLE DB 0 ;flag to disable if cannot uninstall
TSR_MODE DB 1 ;=0 if command line mode
VER3 DB 0 ;=1 if Version >= 3.0
LAST_BLOCK DB 0 ;=1 if last MCB
TABLE_FULL DB 0 ;=1 if table full
CURSOR_POS DW 0 ;to store cursor position
BIOS_SEG DW 40H ;address of bios data area
DIFF DW 0 ;# of chars on a line > 80
N_BLK DB 0 ;Count table entries
OUR_SS DW 0 ; used for stack swap
OUR_SP DW 0
THEIR_SS DW 0
THEIR_SP DW 0
RETADDR DW 0
ADDR_INT9H DD 0 ;to save original vectors
ADDR_INT10H DD 0
BUSY DB 0 ;to store status of int 9 and int 10h
;----------------------------------------------------------------------
; INT9H - entry point for memory-resident mode.
; pressing any key causes entry here.
;----------------------------------------------------------------------
INT9H PROC FAR
STI ;interrupts on
PUSH AX ;save working register
CMP CS:DISABLE,-1 ;if disabled, do nothing
JE NOT_US
IN AL,60H ;get key from keyboard port
CMP AL,HOTKEY ;is it our hotkey?
JNE NOT_US ;if not, exit
MOV AH,2 ;otherwise
INT 16H ;get shift status
AND AL,0FH
CMP AL,SHIFT_MASK ;test the shift status
JNE NOT_US ;if not shift combo, exit
IN AL,61H ;These instructions reset
MOV AH,AL ; the keyboard.
OR AL,80H
OUT 61H,AL
MOV AL,AH
JMP SHORT $+2 ;I/O delay for fast AT's
OUT 61H,AL
CLI ;Disable interrupts and
MOV AL,20H ;reset the int controller
OUT 20H,AL
STI
CMP CS:BUSY,0 ;recursion protection
JNE WE_ARE_BUSY ;dont allow re-entrancy
OR CS:BUSY,INT9_BUSY ;set flag for protection
CALL ADJUST_FOR_VIDEO_MODE
JC CANT_POP_UP ;exit if inappropriate mode
CALL MAIN ;call our program
CANT_POP_UP:
CLI ;disable kbd momentarily
AND CS:BUSY,NOT(INT9_BUSY) ;reset protection
WE_ARE_BUSY:
POP AX ;restore working register
STI
IRET ;return to foreground
NOT_US:
POP AX ;restore working register
CLI ;interrupts off
JMP CS:ADDR_INT9H ;jump to original int 9
INT9H ENDP
;-----------------------------------------------------------------
; ADJUST_FOR_VIDEO_MODE
; check for text modes and set offset for lines > than 80 characters
; in length. sets carry flag if inappropriate mode for pop-up.
;-----------------------------------------------------------------
ADJUST_FOR_VIDEO_MODE PROC NEAR
PUSH BX ;save register
MOV AH,15 ;get present mode
INT 10H
CMP AH,80
JB BAD_MODE ;less than 80 chars per line
MOV CS:BYTE PTR DIFF,AH ;calc the # of chars > 80
SUB CS:BYTE PTR DIFF,80 ;on the line & save in diff
CMP AL,7 ;7 is mono, good mode
JNE TRY_COLOR
MODE_OK:
CLC ;clear carry flag
POP BX ;restore register
RET
TRY_COLOR:
CMP AL,3 ;3 is color 80x25,
JBE MODE_OK ; 2 is B&W 80x25
BAD_MODE:
STC ;not good mode, set carry flag
POP BX ;restore register
RET
ADJUST_FOR_VIDEO_MODE ENDP
;-----------------------------------------------------------------
; MAIN - main routine called by pressing hot key
;-----------------------------------------------------------------
MAIN PROC NEAR
CLD ;strings forward
CALL SWAPIN ;new stack
MOV AX,CS ;our data segment is
MOV DS,AX ; same as CS
CALL GETPOS ;save cursor position
CALL CURSOR_HOME ;cursor to 0,0
CALL SAVE_SCREEN ;save screen
CALL CLEAR_SCREEN ;clear screen
CALL PROGRAM ;construct & display memory map
MOV TABLE_FULL,0 ;reset flag
CALL RESTORE_SCREEN ;put screen back
CALL RESTORE_CURSOR ;cursor to original position
CALL SWAPOUT ;put stack back
RET ;that's all
MAIN ENDP
;-----------------------------------------------------------------
; SWAPIN, SWAPOUT - stack routines
;-----------------------------------------------------------------
SWAPIN PROC NEAR
POP CS:RETADDR ;save callers address
MOV CS:THEIR_SS,SS ;save their stack
MOV CS:THEIR_SP,SP
MOV SS,CS:OUR_SS ;switch to our stack
MOV SP,CS:OUR_SP
PUSH AX ;save all registers
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH ES
PUSH DS
PUSH BP
JMP CS:RETADDR ;return to caller
SWAPIN ENDP
;-----------------------------------------------------------------
SWAPOUT PROC NEAR
POP CS:RETADDR ;save callers address
POP BP ;restore all registers
POP DS
POP ES
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
MOV SS,CS:THEIR_SS ;restore callers stack
MOV SP,CS:THEIR_SP
JMP CS:RETADDR ;return to caller
SWAPOUT ENDP
;-----------------------------------------------------------------
; GETPOS, CURSOR_HOME, RESTORE_CURSOR, SETPOS - cursor routines
;-----------------------------------------------------------------
GETPOS PROC NEAR
MOV AH,3 ;get cursor position
XOR BH,BH ;active page
INT 10H ;get cursor position in dx
MOV CURSOR_POS,DX ; and save
RET
GETPOS ENDP
;----------------------------------------------------------------------
CURSOR_HOME PROC NEAR
XOR DX,DX ;position 0,0
CALL SETPOS ;set cursor position
RET
CURSOR_HOME ENDP
;----------------------------------------------------------------------
RESTORE_CURSOR PROC NEAR
MOV DX,CURSOR_POS ;saved position
CALL SETPOS ;set
RET
RESTORE_CURSOR ENDP
;----------------------------------------------------------------------
SETPOS PROC NEAR
MOV AH,2 ;set cursor position
XOR BH,BH ;active page
INT 10H ;set cursor position to dx
RET
SETPOS ENDP
;-----------------------------------------------------------------
; SAVE_SCREEN, CLEAR_SCREEN, RESTORE_SCREEN - screen routines
;-----------------------------------------------------------------
SAVE_SCREEN PROC NEAR
PUSH DS ;save data segment
XOR AX,AX
MOV BX,AX
CALL CALC_SCRN_ADDR ;address of (0,0)
MOV SI,OFFSET SCREEN ;buffer is past end of table
PUSH DS ;exchange
PUSH ES ;ds and es
POP DS
POP ES
XCHG DI,SI ;exchange source,destination
MOV BX,25 ;save 25 lines
SAVE_NEXT_LINE:
MOV CX,80 ;save 80 words per line
REP MOVSW ;save line
ADD SI,CS:DIFF ;add extra characters and
ADD SI,CS:DIFF ; attributes to SI
DEC BX ;d